//
//  LBSTableViewCell.m
//  LBSYunDemo
//
//  Created by RetVal on 3/25/13.
//  Copyright (c) 2013 RetVal. All rights reserved.
//

#import "LBSTableViewCell.h"
#import "LBSRequestManager.h"
@interface LBSTableViewCell()
{
	@private
	__weak UIImageView *_myImageView;
	__weak UILabel *_nameLabel;
	__weak UILabel *_priceLabel;
	__weak UILabel *_locationLabel;
	__weak UILabel *_distanceLabel;
	NSURL *_imageURL;
}
@property (weak, nonatomic) IBOutlet UIImageView *myImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *locationLabel;
@property (weak, nonatomic) IBOutlet UILabel *distanceLabel;
@property (weak, nonatomic) IBOutlet UILabel *rentalTypeLabel;
@end
@implementation LBSTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
		self.myImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (UIImage *)image
{
	return [self.myImageView image];
}

- (void)setImage:(UIImage *)image
{
	[self.myImageView setImage:image];
}

- (NSString *)name
{
	return [self.nameLabel text];
}

- (void)setName:(NSString *)name
{

    if (name.length > 12) {
        NSString *shortName = [name substringToIndex:11];
        [self.nameLabel setText:[NSString stringWithFormat:@"%@...",shortName]];
    }else {
        [self.nameLabel setText:name];
    }
}

- (NSString *)price
{
	return [self.priceLabel text];
}

- (void)setPrice:(NSString *)price
{
	[self.priceLabel setText:price];
}

- (NSString *)locationInformation
{
	return [self.locationLabel text];
}

- (void)setLocationInformation:(NSString *)locationInformation
{
    if (locationInformation.length > 15) {
        NSString *shortLoc = [locationInformation substringToIndex:13];
        [self.locationLabel setText:[NSString stringWithFormat:@"%@...",shortLoc]];
    }else {
        [self.locationLabel setText:locationInformation];
    }
	}

- (NSString *)distanceInformation
{
	return [self.distanceLabel text];
}

- (void)setDistanceInformation:(NSString *)distanceInformation
{
	[self.distanceLabel setText:distanceInformation];
}

- (NSString *)rentalTypeInformation
{
	return [self.rentalTypeLabel text];
}

- (void)setRentalTypeInformation:(NSString *)rentalTypeInformation
{
	[self.rentalTypeLabel setText:rentalTypeInformation];
}
//- (void)setImageURL:(NSURL *)imageURL
//{
//	if (imageURL)
//	{
//		_imageURL = imageURL;
//		[[LBSRequestManager defaultManager] addRequest:[[LBSRequest alloc] initWithURL:_imageURL] dataComplete:^(LBSRequest *request, id dataModel) {
//			if (dataModel == nil) return ;
//			NSLog(@"LBSTableViewCell load data");
//			_imageView.image = [UIImage imageWithData:dataModel];
//		}];
//	}
//}
@end

